package com.nhc.activity_fragment;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Point;
import android.location.Location;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.astrob.model.LonLat;
import com.astrob.nhcmap.R;
import com.astrob.util.CoordChange;
import com.astrob.util.SysUtils;
import com.astrob.util.Utils;
import com.nhc.model.HCLocationInfo;

import java.text.DecimalFormat;

import zuo.biao.library.base.BaseActivity;
import zuo.biao.library.util.StringUtil;

public class EditLonLatActivity extends BaseActivity implements View.OnClickListener {
    private final String TAG = "EditLonLatActivity";

    static final String INTENT_LONLAT_LL = "INTENT_LONLAT_LL";
    static final String INTENT_LONLAT_STR = "INTENT_LONLAT_STR";
    //启动方法<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    /**
     * 启动这个Activity的Intent
     *
     * @param context
     * @return
     */
    public static Intent createIntent(Context context, LonLat ll) {
        return new Intent(context, EditLonLatActivity.class)
                .putExtra(INTENT_LONLAT_LL, ll);
    }

    public static Intent createIntentStrLL(Context context, String strLL) {
        return new Intent(context, EditLonLatActivity.class)
                .putExtra(INTENT_LONLAT_STR, strLL);
    }
    //启动方法>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    LonLat _ll;//如果为空，则from 查找，输入经纬度导航
    boolean _frommore = false;

    boolean _isDadi = false;

    @Override
    public Activity getActivity() {
        return this;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.editlonlat_activity);

        intent = getIntent();
        _ll = (LonLat) intent.getSerializableExtra(INTENT_LONLAT_LL);
        if (_ll == null) {
            _frommore = true;
            _ll = SysUtils.getInstance().getLL();
        }

        String strLL = intent.getStringExtra(INTENT_LONLAT_STR);
        if (SysUtils.getInstance().coord_format > 2) {
            _isDadi = true;
            if (strLL != null && strLL.length() > 1) {
                int coord_mode = SysUtils.getInstance().coord_mode;
                int coord_format = SysUtils.getInstance().coord_format;
                _ll = CoordChange.getInstance().change2LL(strLL, coord_mode, coord_format);
                _frommore = false;
            }
        } else {
            int coord_mode = SysUtils.getInstance().coord_mode;
//            int coord_format = SysUtils.getInstance().coord_format;
            if (coord_mode != 0 && coord_mode != 3) {
                HCLocationInfo ci = CoordChange.getInstance().getHCL(coord_mode, _ll, SysUtils.getInstance().coord_format);
                _ll = ci.getLL();
            }
        }

        //功能归类分区方法，必须调用<<<<<<<<<<
        initView();
        initData();
        initEvent();
        //功能归类分区方法，必须调用>>>>>>>>>>

        if (_isDadi) {
            llMode0.setVisibility(View.GONE);
            llMode1.setVisibility(View.GONE);
            btn_changetodms.setVisibility(View.GONE);
            findViewById(R.id.ll_mode_dadi).setVisibility(View.VISIBLE);

            if (_ll.GetLon() < 0) {
                _lonIsE = false;
            } else {
                _lonIsE = true;
            }

            if (_ll.GetLat() < 0) {
                _latIsN = false;
            } else {
                _latIsN = true;
            }

            if (strLL == null || strLL.length() < 1) {
                strLL = SysUtils.getInstance().getLLStr(_ll);
            }

            String[] names = strLL.split("\n");
            String[] strLat = names[0].split(" ");
            double lat = Double.parseDouble(strLat[0]);
            double lon = 0;//lon的绝对值

            String[] strLon = names[1].split(" ");
            if (strLon.length == 2) {
                lon = Double.parseDouble(strLon[0]);
            } else if (strLon.length == 3) {
                //"lat" -> "4426419.61 N"
                //"lon" -> "50S 442457.54 E"
                //"lon" -> "50SMK 442457.54 E"
                _UtmZone = strLon[0];
                lon = Double.parseDouble(strLon[1]);
            }

            if (_UtmZone.length() > 0) {
                etEditTextInfodadi_zone.setText(_UtmZone);
            } else {
                etEditTextInfodadi_zone.setVisibility(View.GONE);
            }
            etEditTextInfodadi_lat.setText(lat + "");
            etEditTextInfodadi_lon.setText(lon + "");

            findViewById(R.id.ll_paste).setVisibility(View.GONE);

        } else {
            if (SysUtils.getInstance().coord_format == 2) {
                _mode = 1;
            } else if (SysUtils.getInstance().coord_format == 0) {
                _mode = 0;
            } else {
                _mode = 2;
            }


//            etEdit_paste.setText(SysUtils.getInstance().getLLStr(_ll));
            findViewById(R.id.tv_paste).setOnClickListener(this);
        }

        resetMode(_mode);
    }

    //UI显示区(操作UI，但不存在数据获取或处理代码，也不存在事件监听代码)<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    private LinearLayout llMode0;
    private LinearLayout llMode1;
    private ImageView ivEditTextInfoClearLon;
    private ImageView ivEditTextInfoClearLat;
    private EditText etEditTextInfo_lon;
    private EditText etEditTextInfo_lat;
    private EditText etEditTextInfo_lon_a;
    private EditText etEditTextInfo_lon_b;
    private EditText etEditTextInfo_lon_c;
    private EditText etEditTextInfo_lat_a;
    private EditText etEditTextInfo_lat_b;
    private EditText etEditTextInfo_lat_c;
    private TextView btn_changetodms;
    private TextView tv_lon_t0;
    private TextView tv_lat_t0;
    private TextView tv_lon_t1;
    private TextView tv_lat_t1;

    private TextView tv_londadi_t0;
    private TextView tv_latdadi_t0;

    private EditText etEditTextInfodadi_lon;
    private EditText etEditTextInfodadi_lat;
    private EditText etEditTextInfodadi_zone;

    private EditText etEdit_paste;

    @Override
    public void initView() {//必须调用
        llMode0 = (LinearLayout) findViewById(R.id.ll_mode_0);
        llMode1 = (LinearLayout) findViewById(R.id.ll_mode_1);
        ivEditTextInfoClearLon = (ImageView) findViewById(R.id.ivEditTextInfoClear_lon);
        ivEditTextInfoClearLat = (ImageView) findViewById(R.id.ivEditTextInfoClear_lat);

        etEditTextInfo_lon = (EditText) findViewById(R.id.etEditTextInfo_lon);
        etEditTextInfo_lat = (EditText) findViewById(R.id.etEditTextInfo_lat);

        etEditTextInfodadi_lon = (EditText) findViewById(R.id.etEditTextInfodadi_lon);
        etEditTextInfodadi_lat = (EditText) findViewById(R.id.etEditTextInfodadi_lat);
        etEditTextInfodadi_zone = (EditText) findViewById(R.id.etEditTextInfodadi_zone);

        etEditTextInfo_lon_a = (EditText) findViewById(R.id.etEditTextInfo_lon_a);
        etEditTextInfo_lon_b = (EditText) findViewById(R.id.etEditTextInfo_lon_b);
        etEditTextInfo_lon_c = (EditText) findViewById(R.id.etEditTextInfo_lon_c);
        etEditTextInfo_lat_a = (EditText) findViewById(R.id.etEditTextInfo_lat_a);
        etEditTextInfo_lat_b = (EditText) findViewById(R.id.etEditTextInfo_lat_b);
        etEditTextInfo_lat_c = (EditText) findViewById(R.id.etEditTextInfo_lat_c);

        etEdit_paste = (EditText) findViewById(R.id.etEdit_paste);

        btn_changetodms = (TextView) findViewById(R.id.btn_changetodms);

        tv_lon_t0 = (TextView) findViewById(R.id.tv_lon_t0);
        tv_lat_t0 = (TextView) findViewById(R.id.tv_lat_t0);
        tv_lon_t1 = (TextView) findViewById(R.id.tv_lon_t1);
        tv_lat_t1 = (TextView) findViewById(R.id.tv_lat_t1);

        tv_londadi_t0 = (TextView) findViewById(R.id.tv_londadi_t0);
        tv_latdadi_t0 = (TextView) findViewById(R.id.tv_latdadi_t0);

        TextView btn_save = (TextView) findViewById(R.id.btn_save);
        if (_frommore) {
            btn_save.setVisibility(View.GONE);
            findViewById(R.id.btn_navi).setVisibility(View.VISIBLE);
        }
    }

    String _UtmZone = "";
    //UI显示区(操作UI，但不存在数据获取或处理代码，也不存在事件监听代码)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    //Data数据区(存在数据获取或处理代码，但不存在事件监听代码)<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


    @Override
    public void initData() {//必须调用

    }


    //Data数据区(存在数据获取或处理代码，但不存在事件监听代码)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


    //Event事件区(只要存在事件监听代码就是)<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    private String inputedString;

    @Override
    public void initEvent() {//必须调用
        etEditTextInfo_lon.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                inputedString = StringUtil.getTrimedString(s);
                if (StringUtil.isNotEmpty(inputedString, true) == false) {
                    ivEditTextInfoClearLon.setVisibility(View.GONE);
                } else {
                    ivEditTextInfoClearLon.setVisibility(View.VISIBLE);
                }
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
            }
        });
        ivEditTextInfoClearLon.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                etEditTextInfo_lon.setText("");
            }
        });

        etEditTextInfo_lat.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                inputedString = StringUtil.getTrimedString(s);
                if (StringUtil.isNotEmpty(inputedString, true) == false) {
                    ivEditTextInfoClearLat.setVisibility(View.GONE);
                } else {
                    ivEditTextInfoClearLat.setVisibility(View.VISIBLE);
                }
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
            }
        });
        ivEditTextInfoClearLat.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                etEditTextInfo_lat.setText("");
            }
        });

        btn_changetodms.setOnClickListener(this);
        findViewById(R.id.btn_navi).setOnClickListener(this);

        tv_lon_t0.setOnClickListener(this);
        tv_lat_t0.setOnClickListener(this);
        tv_lon_t1.setOnClickListener(this);
        tv_lat_t1.setOnClickListener(this);

        tv_londadi_t0.setOnClickListener(this);
        tv_latdadi_t0.setOnClickListener(this);

        etEditTextInfodadi_lon.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
            }
        });

        etEditTextInfodadi_lat.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
            }
        });

        etEditTextInfodadi_zone.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
            }
        });

        etEdit_paste.addTextChangedListener(new TextWatcher() {
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }

            @Override
            public void afterTextChanged(Editable s) {
            }
        });

    }
    //系统自带监听方法<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


    //类相关监听<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    boolean _lonIsE = true; //经度(E)
    boolean _latIsN = true; //纬度(N)

    private int _mode = 0;//0-度 1-度分秒 2-度分

    private void resetMode(int mode) {
        if (_isDadi) {
            if (!_lonIsE) {
                tv_londadi_t0.setText(R.string.jduw);
            } else {
                tv_londadi_t0.setText(R.string.jdue);
            }

            if (!_latIsN) {
                tv_latdadi_t0.setText(R.string.wdus);
            } else {
                tv_latdadi_t0.setText(R.string.wdun);
            }
            return;
        }

        findViewById(R.id.ll_mode_dadi).setVisibility(View.GONE);
        _mode = mode;
        if (_mode == 0) {
            btn_changetodms.setText(R.string.changetodms);
            llMode0.setVisibility(View.VISIBLE);
            llMode1.setVisibility(View.GONE);
        } else if (_mode == 1) {
            btn_changetodms.setText(R.string.changetodms_2);
            llMode1.setVisibility(View.VISIBLE);
            llMode0.setVisibility(View.GONE);

            findViewById(R.id.etEditTextInfo_lat_c).setVisibility(View.VISIBLE);
            findViewById(R.id.etEditTextInfo_lat_c1).setVisibility(View.VISIBLE);
            findViewById(R.id.etEditTextInfo_lon_c).setVisibility(View.VISIBLE);
            findViewById(R.id.etEditTextInfo_lon_c1).setVisibility(View.VISIBLE);
        } else if (_mode == 2) {
            btn_changetodms.setText(R.string.changetodms_1);
            llMode1.setVisibility(View.VISIBLE);
            llMode0.setVisibility(View.GONE);

            findViewById(R.id.etEditTextInfo_lat_c).setVisibility(View.GONE);
            findViewById(R.id.etEditTextInfo_lat_c1).setVisibility(View.GONE);
            findViewById(R.id.etEditTextInfo_lon_c).setVisibility(View.GONE);
            findViewById(R.id.etEditTextInfo_lon_c1).setVisibility(View.GONE);
        }


        if (_ll.GetLon() < 0) {
            tv_lon_t0.setText(R.string.jduw);
            tv_lon_t1.setText(R.string.jduw);
            _lonIsE = false;
        } else {
            tv_lon_t0.setText(R.string.jdue);
            tv_lon_t1.setText(R.string.jdue);
            _lonIsE = true;
        }

        if (_ll.GetLat() < 0) {
            tv_lat_t0.setText(R.string.wdus);
            tv_lat_t1.setText(R.string.wdus);
            _latIsN = false;
        } else {
            tv_lat_t0.setText(R.string.wdun);
            tv_lat_t1.setText(R.string.wdun);
            _latIsN = true;
        }

        String weisu = "0.00000000";
        switch (SysUtils.getInstance().ll_mode) {
            default:
            case 0:
                break;
            case 1:
                weisu = "0.000000";
                break;
            case 2:
                weisu = "0.0000000";
                break;
            case 3:
                weisu = "0.00000000";
                break;
        }

        double lon = Math.abs(_ll.GetLon());
        double lat = Math.abs(_ll.GetLat());

        String strLon0 = new DecimalFormat(weisu).format(Math.abs(lon)) + "";
        String strLat0 = new DecimalFormat(weisu).format(Math.abs(lat)) + "";

//        String strLon0 = lon + "";
//        String strLat0 = lat + "";

        etEditTextInfo_lon.setText(strLon0);
        etEditTextInfo_lat.setText(strLat0);

        if (_mode == 1) {
            String[] strLon = gpsInfoConvert(lon);
            String[] strLat = gpsInfoConvert(lat);
            if (strLon.length == 3) {
                etEditTextInfo_lon_a.setText(strLon[0]);
                etEditTextInfo_lon_b.setText(strLon[1]);
                etEditTextInfo_lon_c.setText(strLon[2]);
            }
            if (strLat.length == 3) {
                etEditTextInfo_lat_a.setText(strLat[0]);
                etEditTextInfo_lat_b.setText(strLat[1]);
                etEditTextInfo_lat_c.setText(strLat[2]);
            }
        } else if (_mode == 2) {
            String[] strLon = gpsInfoConvert2(lon);
            String[] strLat = gpsInfoConvert2(lat);
            if (strLon.length == 2) {
                etEditTextInfo_lon_a.setText(strLon[0]);
                etEditTextInfo_lon_b.setText(strLon[1]);
            }
            if (strLat.length == 2) {
                etEditTextInfo_lat_a.setText(strLat[0]);
                etEditTextInfo_lat_b.setText(strLat[1]);
            }
        }

    }

    private String[] gpsInfoConvert(double gpsInfo) {
        gpsInfo = Math.abs(gpsInfo);

        try {
            String dms = Location.convert(gpsInfo, Location.FORMAT_SECONDS);
            String[] splits = dms.split(":");
            String[] strll = {splits[0], splits[1], splits[2]};
            return strll;
        } catch (Exception e) {
            String[] strll = {"", "", ""};
            return strll;
        }
    }

    private String[] gpsInfoConvert2(double gpsInfo) {
        gpsInfo = Math.abs(gpsInfo);

//        String dms = Location.convert(gpsInfo, Location.FORMAT_MINUTES);
//        String[] splits = dms.split(":");
//        String[] strll = {splits[0], splits[1]};
        int a = (int) gpsInfo;
        double b = (gpsInfo - a) * 60;

        String weisu = "0.00000000";
        switch (SysUtils.getInstance().ll_mode) {
            default:
            case 0:
                break;
            case 1:
                weisu = "0.000000";
                break;
            case 2:
                weisu = "0.0000000";
                break;
            case 3:
                weisu = "0.00000000";
                break;
        }
        String strB = new DecimalFormat(weisu).format(Math.abs(b)) + "";

        String[] strll = {a + "", strB};
        return strll;
    }

    @Override
    public void finish() {
        super.finish();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_changetodms:
                _ll = getEditLL();
                if (_ll == null || !_ll.IsValid()) {
                    showShortToast(getString(R.string.zbsrcw));
                    return;
                }
                _mode++;
                if (_mode > 2) {
                    _mode = 0;
                }
                resetMode(_mode);
                break;
            case R.id.btn_navi:
                onMenu();
                break;
            case R.id.tv_lon_t0:
            case R.id.tv_lon_t1:
            case R.id.tv_londadi_t0:
                onLon();
                break;
            case R.id.tv_latdadi_t0:
            case R.id.tv_lat_t0:
            case R.id.tv_lat_t1:
                onLat();
                break;
            case R.id.tv_paste:
                onPaste();
                break;
            default:
                break;
        }

    }

    private void onPaste() {
        // ， 分割 lat，lon
        try {
            String strLL = etEdit_paste.getText().toString();
            strLL = strLL.replace("\n", ",");
            String[] split = strLL.split("[,;:\\s]");
            if (split.length != 4) {
                showShortToast("错误的经纬度格式！");
                return;
            }

            double lat = convertToDegree(split[0]);
            double lon = convertToDegree(split[2]);

            if (split[1] == "W") {
                lat = -lat;
            }
            if (split[3] == "S") {
                lon = -lon;
            }
            _ll.SetLonLat(lon, lat);
        } catch (Exception e) {
            showShortToast("错误的经纬度格式！");
            return;
        }

        showShortToast("已经粘贴经纬度。");

        etEdit_paste.setText("");
        resetMode(_mode);

    }

    double convertToDegree(String strLL) {
        String[] split = strLL.split("[°′″]");

        Double D = new Double(split[0]);
        Double M = new Double(0);
        Double S = new Double(0);

        if (split.length > 1) {
            M = new Double(split[1]);
        }
        if (split.length > 2) {
            S = new Double(split[2]);
        }
        double result = new Double(D + (M / 60) + (S / 3600));
        return result;
    }

    private int[] CTRL_IDS = {
            R.id.btn_changetodms, R.id.btn_navi,
            R.id.tv_lon_t0, R.id.tv_lon_t1, R.id.tv_londadi_t0,
            R.id.tv_latdadi_t0, R.id.tv_lat_t0, R.id.tv_lat_t1
    };

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        switch (keyCode) {
            default:
                break;
            case 21://left
            case 22://right
            case 19://up
            case 20://down
            case 23://ok
                setFoucseCtrl();
                break;
        }
        return super.onKeyUp(keyCode, event);
    }

    boolean _isFirst = true;

    private void setFoucseCtrl() {
        if (!_isFirst) {
            return;
        }

        _isFirst = false;

        for (int i = 0; i < CTRL_IDS.length; i++) {
            findViewById(CTRL_IDS[i]).setFocusable(true);
        }
    }


    private void onLon() {
        _lonIsE = !_lonIsE;
        if (!_isDadi) {
            _ll = getEditLL();
        }
        resetMode(_mode);
    }

    private void onLat() {
        _latIsN = !_latIsN;
        if (!_isDadi) {
            _ll = getEditLL();
        }
        resetMode(_mode);
    }

    public static final String RESULT_VALUE = "RESULT_VALUE";

    @Override
    public void onForwardClick(View v) {
        if (_frommore) {
            return;
        }
        onMenu();
    }

    void onMenu() {
        intent = new Intent();
        if (_isDadi) {
            String strZone = StringUtil.getNumberOrAlpha(etEditTextInfodadi_zone.getText().toString());
            if (_UtmZone.length() > 0 && strZone.length() < 1) {
                //原来有zone，修改后也需要有
                showShortToast(getString(R.string.zbsrcw));
                return;
            }

            if (strZone.length() > 0) {
                strZone += " ";
            }
            String strN = " N";
            if (!_latIsN) {
                strN = " S";
            }
            String strE = " E";
            if (!_lonIsE) {
                strE = " W";
            }
            String strLL = StringUtil.getTrimedString(etEditTextInfodadi_lat) + strN + "\n" + strZone + StringUtil.getTrimedString(etEditTextInfodadi_lon) + strE;

            int coord_mode = SysUtils.getInstance().coord_mode;
            int coord_format = SysUtils.getInstance().coord_format;
            LonLat llA = CoordChange.getInstance().change2LL(strLL, coord_mode, coord_format);
            if (llA == null || llA.IsInvalid()) {
                showShortToast(getString(R.string.zbsrcw));
                return;
            }
            intent.putExtra(RESULT_VALUE, strLL);
        } else {
            LonLat llA = getEditLL();
            if (llA == null || llA.IsInvalid()) {
                showShortToast(getString(R.string.zbsrcw));
                return;
            }
            intent.putExtra(RESULT_VALUE, llA);
        }
        setResult(RESULT_OK, intent);

        exitAnim = zuo.biao.library.R.anim.left_push_out;
        finish();
    }

    LonLat getEditLL() {
        double lon = 0;
        double lat = 0;
        try {
            if (_mode == 0) {
                lon = Double.valueOf(StringUtil.getTrimedString(etEditTextInfo_lon));
                lat = Double.valueOf(StringUtil.getTrimedString(etEditTextInfo_lat));
            } else if (_mode == 1) {
                double lon_a = Double.valueOf(StringUtil.getTrimedString(etEditTextInfo_lon_a));
                double lat_a = Double.valueOf(StringUtil.getTrimedString(etEditTextInfo_lat_a));
                double lon_b = Double.valueOf(StringUtil.getTrimedString(etEditTextInfo_lon_b)) / 60;
                double lat_b = Double.valueOf(StringUtil.getTrimedString(etEditTextInfo_lat_b)) / 60;
                double lon_c = Double.valueOf(StringUtil.getTrimedString(etEditTextInfo_lon_c)) / 3600;
                double lat_c = Double.valueOf(StringUtil.getTrimedString(etEditTextInfo_lat_c)) / 3600;

                lon = lon_a + lon_b + lon_c;
                lat = lat_a + lat_b + lat_c;
            } else if (_mode == 2) {
                double lon_a = Double.valueOf(StringUtil.getTrimedString(etEditTextInfo_lon_a));
                double lat_a = Double.valueOf(StringUtil.getTrimedString(etEditTextInfo_lat_a));
                double lon_b = Double.valueOf(StringUtil.getTrimedString(etEditTextInfo_lon_b)) / 60;
                double lat_b = Double.valueOf(StringUtil.getTrimedString(etEditTextInfo_lat_b)) / 60;

                lon = lon_a + lon_b;
                lat = lat_a + lat_b;
            }
        } catch (NumberFormatException e) {
            return new LonLat();
        }

        if (!_latIsN) {
            lat = -lat;
        }
        if (!_lonIsE) {
            lon = -lon;
        }

        return new LonLat(lon, lat);
    }


    //类相关监听>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    //系统自带监听方法>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


    //Event事件区(只要存在事件监听代码就是)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


    //内部类,尽量少用<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


    //内部类,尽量少用>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

}
